package com.xncoding.other;

import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

public class test01 {

    static class A { }

    static class B extends A { }

    static class C extends A { }
    @Test
    public void t01(){
        List<? super A> listsuper = new ArrayList<>();
        listsuper.add(new A());//编译报错
        listsuper.add(new B());//编译报错
        listsuper.add(new C());//编译报错

        List<A> list = new ArrayList<>();
        list.add(new A());
        list.add(new B());
        List<? extends A> listextends = new ArrayList<>();
        listextends = list;
        System.out.println(listextends.size());
    }

    @Test
    public void t02(){
        List<Integer> integerList = new ArrayList<>();
        for (int i = 0; i < 100; i++) {
            integerList.add(i);
        }
        List<Integer> list = new ArrayList<>();
        integerList.parallelStream().forEach(list::add);
        System.out.println(list);
        System.out.println("---------------------------------------");
        List<Integer> list1 = new ArrayList<>();
        integerList.stream().forEach(list1::add);
        System.out.println(list1);
    }


}
